package com.example.cd5160866.urlapp;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.example.cd5160866.urlapp.utils.Rom;
import com.example.cd5160866.urlapp.view.PermissionPageUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import butterknife.OnLongClick;


public class Demo5Activity extends Activity {
    @InjectView(R.id.btn_choose)
    View btnChoose;
    //    @InjectView(R.id.tv_text)
    //    TextView ivTest;
    //    @InjectView(R.id.v)
    //    View view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo_5);
        List test = new ArrayList();
        ButterKnife.inject(this);
    }


    @OnClick(R.id.btn_choose)
    public void onClick() {
        startActivity(new Intent(this, Demo9WebActivity.class));
    }

    @OnClick(R.id.btn_gps)
    public void gps() {
        Toast.makeText(this, " " + isOPen(getApplicationContext()), Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.white)
    public void white() {
        Rom.goSetting(this, "com.dada.mobile.android", "达达骑士", Rom.ACTION_WHITE);
    }

    @OnClick(R.id.launch)
    public void lauch() {
        Rom.goSetting(this, "com.dada.mobile.android", "达达骑士", Rom.ACTION_AUTO_START);
    }

    @OnClick(R.id.permission)
    public void permission() {
        Rom.goSetting(this, "com.dada.mobile.android", "达达骑士", Rom.ACTION_PERMISSION);
    }

    @OnClick(R.id.notice)
    public void notice() {
        Rom.goSetting(this, "com.dada.mobile.android", "达达骑士", Rom.ACTION_NOTIFICATION);
    }

    @OnLongClick(R.id.notice)
    public boolean noticeCheck() {
        Toast.makeText(this, "" + PermissionPageUtils.isNotificationEnabled(this), Toast.LENGTH_SHORT).show();
        return false;
    }

    public static boolean isOPen(final Context context) {
        LocationManager locationManager
                = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        // 通过GPS卫星定位，定位级别可以精确到街（通过24颗卫星定位，、速度快）
        boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        // 通过WLAN或移动网络(3G/2G)确定的位置（也称作AGPS，辅助GPS定位。主要用于在室内或遮盖物（建筑群或茂密的深林等）密集的地方定位）
        boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (gps || network) {
            return true;
        }
        return false;
    }

}
